package daoBDDImpl;

import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import utils.HibernateUtil;
import bean.Manifestation;
import dao.ManifestationDao;

public class ManifestationDaoBDDImpl extends HibernateDaoSupport implements ManifestationDao{

	
	public ManifestationDaoBDDImpl() {
		super();
		setSessionFactory(HibernateUtil.getSessionFactory());
	}

	
	@Override
	public Manifestation getManifestation(long id) {
		return getHibernateTemplate().get(Manifestation.class,id);
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<Manifestation> getByNom(String nom) {
		return getHibernateTemplate().findByNamedQueryAndNamedParam("getManifestationByName", "nom", nom);
	}

	@Override
	public void delManifestation(Manifestation manifestation) {
		getHibernateTemplate().delete(manifestation);
	}

	@Override
	public void setManifestation(Manifestation manifestation) {
		getHibernateTemplate().save(manifestation);
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<Manifestation> getAll() {
		return getHibernateTemplate().findByNamedQuery("getAllManifestation");
	}
}
